package com.j2eefast.flowable.bpm.service;

import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmTemptagEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmTemptagMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 临牌Service接口
 * @author: yhli
 * @date 2020-06-24 17:03
 */
@Service
public class bpmCrmTemptagService extends ServiceImpl<bpmCrmTemptagMapper,bpmCrmTemptagEntity> {

	@Resource
	private bpmCrmTemptagMapper bpmCrmTemptagMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmTemptagEntity> queryWrapper = new QueryWrapper<bpmCrmTemptagEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String orderRegistrantName = (String) params.get("orderRegistrantName");
        queryWrapper.like(ToolUtil.isNotEmpty(orderRegistrantName), "order_registrant_name", orderRegistrantName);
          String orderRegistrantAddress = (String) params.get("orderRegistrantAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRegistrantAddress), "order_registrant_address", orderRegistrantAddress);
          String orderRegistrantPhone = (String) params.get("orderRegistrantPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRegistrantPhone), "order_registrant_phone", orderRegistrantPhone);
          String orderIsNeedMail = (String) params.get("orderIsNeedMail");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsNeedMail), "order_is_need_mail", orderIsNeedMail);
          String orderRecipientisregistrant = (String) params.get("orderRecipientisregistrant");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderRecipientisregistrant), "order_recipientisregistrant", orderRecipientisregistrant);
          String orderRecipientName = (String) params.get("orderRecipientName");
        queryWrapper.like(ToolUtil.isNotEmpty(orderRecipientName), "order_recipient_name", orderRecipientName);
          String orderRecipientAddress = (String) params.get("orderRecipientAddress");
        queryWrapper.like(ToolUtil.isNotEmpty(orderRecipientAddress), "order_recipient_address", orderRecipientAddress);
          String orderRecipientPhone = (String) params.get("orderRecipientPhone");
        queryWrapper.like(ToolUtil.isNotEmpty(orderRecipientPhone), "order_recipient_phone", orderRecipientPhone);
             String selectTempTagNumber = (String) params.get("selectTempTagNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(selectTempTagNumber), "select_temp_tag_number", selectTempTagNumber);
          String shippingInfo = (String) params.get("shippingInfo");
         queryWrapper.eq(ToolUtil.isNotEmpty(shippingInfo), "shipping_info", shippingInfo);
          String shippingFee = (String) params.get("shippingFee");
         queryWrapper.eq(ToolUtil.isNotEmpty(shippingFee), "shipping_fee", shippingFee);
          String tempTagFee = (String) params.get("tempTagFee");
         queryWrapper.eq(ToolUtil.isNotEmpty(tempTagFee), "temp_tag_fee", tempTagFee);
          String totalFee = (String) params.get("totalFee");
         queryWrapper.eq(ToolUtil.isNotEmpty(totalFee), "total_fee", totalFee);
  		Page<bpmCrmTemptagEntity> page = bpmCrmTemptagMapper.selectPage(new Query<bpmCrmTemptagEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmTemptagEntity bpmCrmTemptagEntity) {
		Page<bpmCrmTemptagEntity> page = bpmCrmTemptagMapper.findPage(new Query<bpmCrmTemptagEntity>(params).getPage(), bpmCrmTemptagEntity,(String) params.get(Constant.SQL_FILTER))  ;

		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmTemptagByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmTemptagById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmTemptag(bpmCrmTemptagEntity bpmCrmTemptag){
        bpmCrmTemptag.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmTemptag);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmTemptagById(bpmCrmTemptagEntity bpmCrmTemptag) {
		return updateById(bpmCrmTemptag);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmTemptagEntity getbpmCrmTemptagById(String id){
		return getById(id);
	}
}
